package com.boilerCloud.service.repair;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.boilerCloud.dao.repair.RepairPlanDao;
import com.boilerCloud.dao.work.WorkOrderDao;
import com.boilerCloud.dto.HzlqswPage;
import com.boilerCloud.dto.repair.RepairPlan;
import com.boilerCloud.dto.work.WorkOrder;
import com.boilerCloud.util.RedisPoolsUtil;
import com.boilerCloud.util.StringUtil;

@Service
public class RepairPlanServiceImpl implements IRepairPlanService {

	@Resource
	private RepairPlanDao dao;
	
	@Resource
	private WorkOrderDao workOrderdao;
	@Override
	public void qryList(RepairPlan model, HzlqswPage<RepairPlan> page)
			throws Exception {
		dao.qryList(model,page);
		
	}

	@Override
	public void edit(RepairPlan model) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public RepairPlan getById(int id) throws Exception {
		// TODO Auto-generated method stub
		return dao.getById(id);
	}

	@Override
	public void save(RepairPlan model) throws Exception {
		String repairNo = "E"+StringUtil.DateToString(new Date(), 2) + RedisPoolsUtil.getCounter("repair_counter");
		model.setRepairNo(repairNo);
		dao.save(model);
		
	}

	@Override
	public void del(int id) throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void saveWorkOrder(WorkOrder model) throws Exception {
		String workNo = "W"+StringUtil.DateToString(new Date(), 2) + RedisPoolsUtil.getCounter("work_counter");
		model.setOrderNo(workNo);
		model.setStatus(1);
		model.setOrderType(2);
		model.setRepairId(model.getId());
		workOrderdao.save(model);
		dao.updateStatus(model.getId(), 2);
		
	}

	

}
